import instance from './index';
import qs from 'qs';

const preUrlPath = '';
//获取用户列表-分页
const request = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/user/fetchPageList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取用户列表-不分页
const requestList = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/user/fetchUserList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取用户银行卡列表
const requestBank = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/user/fetchUserBankList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//添加用户
const add = {
  p: ['api:user:new'],
  r: params => {
    return instance.post(`/user/new`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//获取用户信息
const info = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/user/info`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//添加用户个人钱包
const addWallet = {
  p: ['api:user:new'],
  r: params => {
    return instance.post(`/v1/userWallet/new`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//编辑用户个人钱包信息
const modifyWallet = {
  p: ['api:user:new'],
  r: params => {
    return instance.post(`/v1/userWallet/modify`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//获取用户钱包列表
const getUserWallet = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/userWallet/fetchPageList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取用户钱包信息
const getUserWalletInfo = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/userWallet/info`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//删除用户个人钱包
const removeWallet = {
  p: ['api:user:delete'],
  r: params => {
    return instance.delete(`/v1/userWallet/del`,{params})
  }
};


//用户身份验证
const identAuth = {
  p: ['api:user:modify'],
  r: params => {
    return instance.post(`/v1/user/userIdentifyAuth`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};

//用户修改资金密码
const setPayPassword = {
  p: ['api:user:modify'],
  r: params => {
    return instance.post(`/v1/user/modifyPayPassword`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//用户修改密码
const setPassword = {
  p: ['api:user:modify'],
  r: params => {
    return instance.post(`/v1/user/modifyPassword`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};

//越权请求
const notAllowed = {
  p: ['get,/roles/notAllowed'],
  r: params => {
    return instance.get(`${preUrlPath}/GET/roles/notAllowed`, {params})
  }
}

export {
  request,
  removeWallet,
  notAllowed,
  add,
  modify,
  info,
  identAuth,
  requestList,
  getUserWallet,
  getUserWalletInfo,
  modifyWallet,
  addWallet,
  requestBank,
  setPayPassword,
  setPassword,
}
